﻿using System;
using System.Collections.Generic;
using System.Text;
using CuteEditor;
using NLBS.Providers;
using System.Web.UI.WebControls;
using System.Drawing;
        
        //CuteEditor.Editor
namespace NLBS.Editors
{
    /// <summary>
    /// Summary description for PlainTextRichTextEditorProvider.
    /// </summary>
    public class CuteEditorProvider : BlogEntryEditorProvider
    {
        

        Editor _cuteCtl;
        int _rows;
        int _cols;
        string _cssClass;

        //private static System.Resources.ResourceManager rm = new System.Resources.ResourceManager("Subtext.Web.Providers.BlogEntryEditor.PlainText.resources.ErrorMessages", System.Reflection.Assembly.GetExecutingAssembly());

        public override System.Web.UI.Control RichTextEditorControl
        {
            get
            {
                return _cuteCtl;
            }
        }

        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection configValue)
        {
            base.Initialize(name, configValue);
        }

        public override void InitializeControl()
        {

            _cuteCtl = new Editor();
            _cuteCtl.ID = this.ControlId;
            _cuteCtl.Width = Unit.Parse("100%");
            //_cuteCtl.FilesPath = "~/Extensions/CuteSoft_Client/CuteEditor";
            _cuteCtl.AutoConfigure = AutoConfigure.Full;
            _cuteCtl.FrameStyle.BackColor=Color.White;
            WebColorConverter wcc = new WebColorConverter();
            _cuteCtl.FrameStyle.BorderColor = (Color)wcc.ConvertFrom("#DDDDDD");
            _cuteCtl.FrameStyle.BorderWidth = Unit.Parse("1px");
            _cuteCtl.FrameStyle.BorderStyle = BorderStyle.Solid;
            _cuteCtl.FrameStyle.CssClass = "CuteEditorFrame";
            _cuteCtl.FrameStyle.Height = Unit.Parse("250px");
            _cuteCtl.FrameStyle.Width = Unit.Parse("100%");

            int pos = _cuteCtl.ToolControls.IndexOf("Italic") + 20;
            System.Web.UI.WebControls.WebControl ctrl = _cuteCtl.CreateCommandButton("myinsertbutton", "csharp.gif", "插入代码");
            ctrl.Attributes.Add("onclick", "ShowMyDialog(this)");
            _cuteCtl.InsertToolControl(pos, "myinsertbutton", ctrl);

            
        }

        public override String Text
        {
            get
            {
                return _cuteCtl.Text;
            }
            set
            {
                _cuteCtl.Text = value;
            }
        }

        public override String Xhtml
        {
            get
            {
                return _cuteCtl.XHTML;
            }
        }
    }
}
